package com.example.http.websocket.level2;

import javax.security.auth.Subject;
import java.security.Principal;
import java.util.HashMap;
import java.util.Map;

/**
 * @author zhouxl
 * @DATE 2021/1/29
 * @descriptoin
 */
public class User implements Principal {

    private String name;

    public static User getUser(String token) {
        Map<String, String> tokens = new HashMap<>();
        tokens.put("111", "111");
        tokens.put("222", "111");
        tokens.put("333", "111");
        tokens.put("444", "111");
        return tokens.get(token) != null ? new User(token) : null;
    }

    public User(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean implies(Subject subject) {
        return false;
    }
}
